<template>
	<view class="mine">
		<view class="tit">
			<text>我的</text>
			<view class="got">···</view>
		</view>
		<view class="user">
			<view class="box" @click="login">
				<image src="../../static/logo.png"></image>
				<view class="right_user" v-if="!changeFlag">
					<text class="cont">立即登录</text>
					<view class="las">登录解锁更多功能</view>
				</view>
				<view class="right_user" v-if="changeFlag">
					<text class="cont">{{user.username}}</text>
					<view class="las">暂无描述</view>
				</view>
			</view>
			<view class="nav">
				<view class="child" v-for="(item,index) in navs" :key="index">
					<u-icon :name="item.icon" size="18" :color="item.color"></u-icon>
					<view class="text">{{item.title}}</view>
				</view>
			</view>
		</view>
		<view class="list">
			<view class="child" v-for="(item,index) in list" :key="index">
				<view class="test">
					<u-icon :name="item.icon" size="12" :color="item.color"></u-icon>
					<text>{{item.title}}</text>
				</view>
				<u-icon name="arrow-right" size="12"></u-icon>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				navs:[
					{icon:'order',title:'订单',color:"#FEBD00"},
					{icon:'chat',title:'消息',color:"#FEBD00"},
					{icon:'star',title:'收藏',color:"#FEBD00"},
					{icon:'file-text',title:'在学',color:"#FEBD00"}
				],
				list:[
					{icon:'coupon',title:'优惠券',color:"#4396EC"},
					{icon:'question-circle',title:'常见问题',color:"#4396EC"},
					{icon:'grid',title:'设置',color:"#4396EC"},
				],
				changeFlag:false,
				user:'',
			}
		},
		onShow() {
			this.user = uni.getStorageSync('user');
			if(this.user != ''){
				this.changeFlag = true;
			}
		},
		methods: {
			login(){
				if(this.user == ''){
					uni.navigateTo({
						url:'../login/login'
					})
				}else{
					uni.navigateTo({
						url:'../user-page/user-page'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.mine{
		width: 100%;
		box-sizing: border-box;
		.tit{
			width: 100%;
			height: 45rpx;
			font-size: 16rpx;
			color: #fff;
			line-height: 45rpx;
			background-color: #5ccc84;
			position: relative;
			text-align: center;
			.got{
				position: absolute;
				top: 50%;
				right: 15rpx;
				transform: translate(0,-50%);
				font-size: 30rpx;
			}
		}
		.user{
			height: 350rpx;
			background-color: #5ccc84;
			border-radius: 0 0 20% 20%;
			position: relative;
			.box{
				width: 100%;
				height: 120rpx;
				display: flex;
				flex-direction: row;
				image{
					width: 124rpx;
					height: 124rpx;
					background-color: #fff;
					border-radius: 50%;
					margin: 30rpx;
				}
				.right_user{
					margin-top: 40rpx;
					margin-left: 25rpx;
					.cont{
						font-size: 34rpx;
						font-weight: bold;
						color: #fff;
					}
					.las{
						color: #fff;
						margin-top: 15rpx;
						font-size: 26rpx;
					}
				}
			}
			.nav{
				width: 690rpx;
				height: 126rpx;
				background: #fff;
				box-shadow: 0 0 4rpx #ccc;
				border-radius: 6rpx;
				position: absolute;
				bottom: 16rpx;
				left: 50%;
				transform: translate(-50%,0);
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				.child{
					width: 25%;
					text-align: center;
					margin-top: 20rpx;
					.u-icon{
						margin-left: 40%;
					}
					.text{
						margin-top: 15rpx;
						font-size: 20rpx;
					}
				}
			}
		}
		.list{
			padding: 20rpx 35rpx;
			.child{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				border-bottom: 2rpx solid #ccc;
				padding: 20rpx 10rpx;
				.test{
					display: flex;
					flex-direction: row;
					font-size: 12rpx;
					line-height: 24rpx;
					.u-icon{
						margin-right: 20rpx;
					}
				}
			}
			.child:last-child{
				border: 0;
			}
		}
	}
</style>
